package fr.upstlse.glre.client.espacededie.commun.depot.action;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.store.StoreFilter;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.form.ComboBox;

import fr.upstlse.glre.client.RfgConstante;
import fr.upstlse.glre.client.espacededie.commun.depot.Telecharger;

public class FilterSelectionAction implements Listener<FieldEvent> {

	Telecharger telechargerPanel;
	Store<ModelData> store;
	StoreFilter<ModelData> documentViewerFilter;
	ComboBox filterComboBox;
	String libelleCourant;

	public FilterSelectionAction(Telecharger pTelechargerPanel,
			Store<ModelData> store,
			StoreFilter<ModelData> documentViewerFilter,
			ComboBox filterComboBox) {
		super();
		telechargerPanel = pTelechargerPanel;
		this.store = store;
		this.documentViewerFilter = documentViewerFilter;
		this.filterComboBox = filterComboBox;
	}

	public void handleEvent(FieldEvent be) {
		telechargerPanel.setLibelleCourant((String) filterComboBox
				.getValue().get(
						RfgConstante.LIBELLE_MODELDATA_INTITULE));
		Info.display("Filtrage", "Documents du libellé "
				+ telechargerPanel.getLibelleCourant(), "");
		store.applyFilters(RfgConstante.DEPOT_MODELDATA_LIBELLE);
	}

}
